#include <stdio.h>

struct Solution
{
	int length;
	int last;
};

static const int MAX_LENGTH = 1000;
Solution solutions[MAX_LENGTH];

int main()
{
	int n;
	scanf ("%d", &n);
	bool first = true;
	while (n--)
	{
		int l;
		scanf ("%d", &l);

		int max = 0;
		int index = 0;
		while (l--)
		{
			int num;
			scanf ("%d", &num);

			int len = 0;
			for (int i = 0; i < index; i++)
			{
				if (solutions[i].last < num && solutions[i].length > len)
					len = solutions[i].length;
			}
			solutions[index].last = num;
			solutions[index].length = len + 1;
			if (len + 1 > max)
				max = len + 1;
			index ++;
		}

		if (!first)
		{
			printf ("\n");
		}
		first = false;
		printf ("%d\n", max);
	}
}